using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace FicheroBinario
{
    class Program
    {
        static void LeerFichero() {
            IFormatter f = new BinaryFormatter();
            FileStream fs = new FileStream("fichero.bin", FileMode.Open);
            A b = (A)f.Deserialize(fs);
           
            Console.WriteLine(b.B);
        }
        static void CreaFichero()
        {
            IFormatter f = new BinaryFormatter();
            FileStream fs = new FileStream("fichero.bin", FileMode.Create);
            A objeto = new A();
            objeto.B = 4;
            f.Serialize(fs, objeto);
            fs.Close();
        }
        static void Main(string[] args)
        {
            CreaFichero();
            LeerFichero();
            
        }
    }
}
